﻿using Microsoft.Extensions.DependencyInjection;

namespace cap01.Core.Annotations;


[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class HuaskyApiServiceAttribute : Attribute
{
    public Type ServiceType { get; set; }

    public ServiceLifetime ServiceLifetime { get; set; } = ServiceLifetime.Scoped;

    public ServiceDescriptor CreateDescriptor(Type implementationType)
    {
        var serviceType = this.ServiceType ?? implementationType;
        return new ServiceDescriptor(serviceType, implementationType, ServiceLifetime);
    }
}
